var login = {
	create : function(container) {
		$(container).load("parts/login.html #login-content", function(){
			$("#auth-send").bind("click", function(){
				var _username = $("#auth-username").val();
				var _password = $("#auth-password").val();
				
				if(_username && _password){
					$.post("/dotcao/ws/users/auth", {username: _username, password: _password}, function(data){
						$("<div />").html(data.content).appendTo("#content").dialog({
							title : "Autenticação",
							show : "fade",
							hide : "fade",
							modal: true,
							width : 300,
							height : 150,
							buttons : {
								OK : function() {
									$(this).dialog("close");
								}
							}
						});
					});
				}
			});
			
			$("#auth-register").bind("click", function() {
				var email = $("#register-email").val();
				var name = $("#register-name").val();
				
				if (email) {
					$.get("/dotcao/ws/users/register/" + email + "/" + name, function(data) {
						$("<div />").html(data.content).appendTo("#content").dialog({
							title : "Solicitação de Registro",
							show : "fade",
							hide : "fade",
							width : 300,
							height : 150,
							buttons : {
								OK : function() {
									$(this).dialog("close");
								}
							}
						});
					}, "json");
				}
				
				return false;
			});
		});
	}
};